package com.mgface.thymeleaf.shiro;

import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.subject.Subject.Builder;
import org.apache.shiro.util.Factory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ManualSubject {
	private static final Logger log = LoggerFactory.getLogger(ManualSubject.class);
	public static void main(String[] args) {
		Factory<org.apache.shiro.mgt.SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini");
		SecurityManager securityManager = factory.getInstance();
		Subject subject = new Builder(securityManager).buildSubject();
		log.info("subject:{}",subject);
		subject.getSession().setAttribute("a2", "a22");
		log.info(subject.getSession().getAttribute("a2").toString());
		subject.execute(()->{
			subject.getSession().setAttribute("a1", "a11");
		});
		log.info(subject.getSession().getAttribute("a1").toString());
	}

}
